import React from 'react';
import { Button } from 'antd';
import http from '../../api/http.js'
export function stopCarStatus(st){
    if(st===1){
        return '闲置'
    }
    if(st===2){
        return '租用'
    }
    if(st===3){
        return '自用'
    }
    if(st===4){
        return '人防'
    }
}
export function yeZhuStatus(st){
    if(st===1){
        return '自住'
    }
    if(st===2){
        return '闲置'
    }
    if(st===3){
        return '装修'
    }
    if(st===4){
        return '出租'
    }
}
export function shenFen(st){
    if(st===1){
        return '业主'
    }
    if(st===2){
        return '家属'
    }
    if(st===3){
        return '租客'
    }
}
export function fangWuType(st){
    if(st===0){
        return (<span style={{ color: '#3399FF' }}>待审核</span>)
    }
    if(st===1){
        return (<span style={{ color: '#333333' }}>已审核</span>) 
    }
    if(st===2){
        return (<span style={{ color: '#f56047' }}>已拒绝</span>) 
    }
}
export const HEAD_CONF = {
    GOODS_LIST: {//商品订单
        head: ['订单编号', '收货地址','收货人电话', '订单价格 ','下单时间','操作'],
        dele_title: "删除商品订单信息",
        inp_ziduan:"搜索：订单编号",
        is_shiw_tbhead: 5,
        is_add:false
    },
}
export function mapAddressToTd(path, item, methods) {
    if (path === "/index/goods_order") {   // GOODS_LIST
        return (
            <tr key={item.id}>
                <td >{item.internal_order_sn}</td>
                <td >{item.full_address}</td>
                <td >{item.mobile}</td>
                <td >{item.order_total_price&&item.order_total_price+'￥'}</td>
                <td >{item.created_at}</td>
                <td style={{ width: '17%' }}>
                    <Button style={{background:'##3399FF'}} type="primary" shape="round" className="table-list-xiugai-f"onClick={(e) => methods.toGoodsDetails(item, e)}>
                        详情
                    </Button>
                </td>
            </tr>
        )
    }
}

export function getPageTotal(path, condition) {
    return new Promise((resolve, reject) => {//小区公告
        
    })
}
export function getTableList(path, page, limit, condition,date,status,service) {//获取表格数据
    return new Promise((resolve, reject) => {
        if (path === "/index/goods_order") {//商品列表
            http('/admin/order_list', { method: 'get' , data: { page: page, limit: limit, condition: condition,status:status } }).then(res => {
                resolve(res.data)
            }).catch(res => {
                reject(res)
            })
        }
    })
}
export function deleItem(path, id) {//删除按钮
    return new Promise((resolve, reject) => {
        if (path === "/index/notice_list") {//小区公告
            http('/notice/noticeDel', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/repair_manage") {//报修管理
            http('/repair/del', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/quarters_list") {//小区列表
            http('/community/community_delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/household_list") {//住户列表
            http('/community/delete_household', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/water_list") {//水费列表
            http('/payment/delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/gas_list") {//气费列表
            http('/payment/delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/electricity_list") {//电费列表
            http('/payment/delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/property_list") {//物业列表
            http('/payment/delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/garbage_list") {//垃圾列表
            http('/payment/delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/stopcar_list") {//停车列表
            http('/payment/delete', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/parking_list") {//停车位列表
            http('/park/del_park_floor', { method: 'POST', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
        if (path === "/index/ye_list") {//业主列表
            http('/owner/owner_delete', { method: 'get', data: { id: id } }).then(res => {
                resolve(res)
            }).catch(res => {
                reject(res)
            })
        }
    })
}